package study.stream;

import study.User;
import study.Utils;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Author 刘伟涛
 * @Date 2024/1/12 15:51
 **/
public class ToMapDemo1 {
    public static void main(String[] args) {
        List<User> userList = Utils.getUserList();
        List<User> anyUserList = Utils.getAnyUserList(20);
        Map<String, Integer> collect = anyUserList.stream().collect(Collectors.toMap(User::getName, User::getId, (v1, v2) -> v2));
        for (String str : collect.keySet()) {
            System.out.println("id:" + str + "name:" + collect.get(str));
        }
    }
}
